﻿namespace CoMiCommon
{
    using System;
    using System.IO;
    using System.Web;

    public class Log
    {
        public static string FILE_NAME = (HttpContext.Current.Server.MapPath("~/logs") + "//" + DateTime.Now.ToString("MMdd") + ".log");

        public static void error(string Node, string message)
        {
            try
            {
                if (File.Exists(FILE_NAME))
                {
                    StreamWriter writer = File.AppendText(FILE_NAME);
                    writer.WriteLine("------------------------------------");
                    writer.WriteLine("[" + DateTime.Now.ToString() + "][" + Node + "]：" + message);
                    writer.Close();
                }
                else
                {
                    StreamWriter writer2 = File.CreateText(FILE_NAME);
                    writer2.WriteLine("[" + DateTime.Now.ToString() + "][" + Node + "]：" + message);
                    writer2.Close();
                }
            }
            catch
            {
            }
        }
    }
}

